package com.yiqi.news.mvp.model

import android.app.Application
import com.google.gson.Gson
import com.jess.arms.integration.IRepositoryManager
import com.jess.arms.mvp.BaseModel

import com.jess.arms.di.scope.ActivityScope
import com.yiqi.news.entity.BaseResponse
import com.yiqi.news.entity.News
import com.yiqi.news.entity.NewsDetail
import com.yiqi.news.entity.ReplyVO
import javax.inject.Inject

import com.yiqi.news.mvp.contract.NewsDetailContract
import com.yiqi.news.mvp.model.api.service.CommonService
import com.yiqi.news.mvp.model.api.service.NewsService
import io.reactivex.Observable


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 06/19/2019 18:01
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@ActivityScope
class NewsDetailModel
@Inject
constructor(repositoryManager: IRepositoryManager) : BaseModel(repositoryManager), NewsDetailContract.Model {
    override fun replyMessage(map: java.util.HashMap<String, String>): Observable<BaseResponse<NewsDetail>> {
        return mRepositoryManager.obtainRetrofitService(CommonService::class.java).replyMessage(map)
    }

    override fun getCommentReply(map: HashMap<String, Any?>): Observable<BaseResponse<List<ReplyVO>>> {
        return mRepositoryManager.obtainRetrofitService(NewsService::class.java).getReply(map)
    }

    override fun toComment(map: HashMap<String, Any?>): Observable<BaseResponse<NewsDetail>> {
        return mRepositoryManager.obtainRetrofitService(NewsService::class.java).commentNews(map)
    }

    override fun toLike(map: HashMap<String, Any?>): Observable<BaseResponse<NewsDetail>> {
        return mRepositoryManager.obtainRetrofitService(NewsService::class.java).likeNews(map)
    }

    override fun toCollection(map: HashMap<String, Any?>): Observable<BaseResponse<NewsDetail>> {
        return mRepositoryManager.obtainRetrofitService(NewsService::class.java).collectionNews(map)
    }

    override fun getNewsDetail(newsId: String, userId: String): Observable<BaseResponse<NewsDetail>> {
        return mRepositoryManager.obtainRetrofitService(NewsService::class.java).newsDetail(newsId, userId)
    }

    @Inject
    lateinit var mGson: Gson
    @Inject
    lateinit var mApplication: Application

    override fun onDestroy() {
        super.onDestroy();
    }
}
